class Person {
  String head = '头';
  String body = '身体';
  num? money;
  Person(this.money);
  sayHi() {
    print('耶耶耶');
  }
}

//适合用在继承以外的场景
mixin RunMixin {
  run() {
    print('小步块跑');
  }
}
mixin BagMixin {
  String? books;
  setBook(String books) {
    this.books = books;
  }
}

class Student extends Person with RunMixin, BagMixin {
  //子类需要重写构造函数传递初始值给父类
  Student(super.money);
}

class Cooker extends Person {
  Cooker(super.money);
}

void main() {
  final s = Student(1);
  print(s.body);
  print(s.head);
  s.sayHi();
  print(s.money);

  s.run();

  s.setBook('语文书');
  print(s.books);
}
